Skip to content

Notification migrate - #899

Open
SailingBoat762 wants to merge 4 commits into
masterfrom
notification-migrate
Open

SailingBoat762 wants to merge 4 commits into
masterfrom
notification-migrate

Conversation

@SailingBoat762

Copy link
Copy Markdown
Contributor

No description provided.

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:请求修改

阻塞问题(1 项):按配置时区调度后,每日自动化在夏令时前拨时可能漏跑,影响迁移后的每日提醒,也影响已有每日自动化。详见行内评论。

验证范围:用当前提交的 APScheduler 调度和扫描代码、SQLite 及替代队列复现;未验证实际 Redis 和通知送达。


def scheduled_scan(self):
sched = BlockingScheduler()
sched = BlockingScheduler(timezone=TIME_ZONE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[阻塞] 夏令时前拨会漏跑每日自动化

改用配置时区后,相邻两个本地 09:00 可能只相差 23 小时。用 America/New_York 的前拨日期验证,09:00 的 cron 正常到点,但扫描 SQL 仍要求距上次执行严格超过 23 小时,导致已有本日应执行的规则未入队;普通 24 小时间隔的对照正常。

建议修复:用配置时区下的计划执行时段去重,不用固定 UTC 小时间隔判断当天是否已执行。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 33481a0 复验:这条「夏令时前拨导致每日任务未入队」的问题已修复。纽约 2026-03-08 本地 09:00 距上次执行只有 23 小时,旧提交 b69d7b0 未入队;当前提交以本地日界线查询,09:00 正常入队(scheduled_at 为 2026-03-08T09:00:00-04:00),同一当地日期已有执行记录的对照仍未入队。这里仅确认扫描阶段修复,不代表 worker 已执行通知。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新到 f462761:前次验证通过的本地日界线扫描和 tests/test_scheduled_automation.py 已撤回。用实际 APScheduler、扫描 SQL(SQLite)和替代队列复验:纽约 2026-03-08 本地 09:00 正常到点,但若上次运行在前一天 09:00(相差 23 小时),本次不会入队;33481a0 在相同条件下入队,无历史和 24 小时间隔对照也能入队。当前行为与目标分支、旧提醒的 23 小时阈值一致,不是这次迁移新引入的问题。先按既有行为评估本 PR;若以后修复夏令时,请恢复本地日界线及回归测试,并把测试接入 CI。

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论:请求修改。除已有的夏令时前拨漏入队问题外,已复现独立的混合时区问题:events 按配置时区成功入队,当前 automation-worker 仍按执行进程的本地时钟再次校验,配置与进程时钟不一致时会丢弃任务。请将生产者与消费者的计划时段作为同一份契约发布。

Comment thread dtable_events/automations/entities.py Outdated
def is_cron_time_matched(self):
if self.run_condition not in CRON_CONDITIONS:
return False
cur_datetime = datetime.now(tz=ZoneInfo(TIME_ZONE))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[阻塞] 生产者按配置时区入队,但 automation-worker 仍用进程本地时钟二次判定。以两个进程都运行在 UTC、events 的 TIME_ZONE 配置为 Asia/Shanghai 为例:现有每日 09:00 规则在 01:00 UTC 正常入队,但 automation-worker 主分支 1730aba 的 AutomationRule.do_actions() 里,can_do_actions() 用 datetime.now() 得到 01:00,直接返回且不执行动作。用实际 cron、扫描、队列序列化和 worker 的执行门槛验证:普通日期、无历史也能复现;旧生产者/UTC worker 与新生产者/上海本地时钟的对照均可进入执行。这与夏令时 SQL 漏入队不同。建议让任务携带已确认的计划时刻和时区,worker 按同一计划时段校验,并为新旧版本混合部署加回归测试。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前提交 33481a0 已在 dtable_events/automations/entities.py:47 把带偏移的 scheduled_at 写入队列;剩余阻塞在消费端。把真实序列化的任务送进 automation-worker main(1730aba)的队列循环:automation_worker/automations/worker.py:67–81 构造 AutomationRule 时未转交此字段。上海每日 09:00 的任务在 01:00 UTC 正常出队,但 UTC worker 仍按进程本地时间判断并跳过动作;时钟对齐的对照能进入动作阶段。请配套让 worker 读取并使用 scheduled_at,兼容没有该字段的旧任务,并在发布新调度前验证新旧生产者与消费者的组合。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f462761 已撤回配置时区调度及 scheduled_at,前次要求先发布兼容该字段的 worker 不再适用于本 PR。复验:当 events 和 worker 都运行在 UTC、配置为 Asia/Shanghai 时,旧候选版在 01:00 UTC 可入队却过不了 worker 的小时判断;当前版本改为 09:00 UTC 入队,并通过 #28 的执行门槛。这里验证的是入队与执行门槛,不是通知送达。events 与 worker 的进程时区仍应一致;迁移时生成星期的独立问题由 dtable-web #6244 原线程追踪。

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论:请求修改,暂不开放定时提醒迁移。

已修复:夏令时前拨时,每日规则按配置时区的日期边界筛选,原先相隔 23 小时漏入队的场景已通过复验。行内复验

仍阻塞:本提交已携带 scheduled_at,但当前 automation-worker 未传递或使用该字段,时区不同的进程仍会在出队后丢弃任务。请先发布兼容有、无该字段的消费者,再启用新调度并验证通知送达。行内复验

验证使用实际 cron、SQLite 扫描和 worker 队列循环,替代 Redis 与通知发送;未验证生产环境实际送达。

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论:请求修改。夏令时前拨的每日入队测试在隔离环境中通过,但 CI 未执行这条回归测试,详见行内评论。独立发布阻塞仍在:automation-worker #28 修复了过滤器分组,但未消费 scheduled_at;将本 PR 序列化的上海 09:00 任务交给 #28 的出队循环,UTC 01:00 会跳过,09:00 对照通过执行门槛。请先发布兼容有、无该字段的 worker,再启用新调度。既有消费端线程;未验证实际通知送达。

Comment thread tests/test_scheduled_automation.py Outdated

class ScheduledAutomationTest(unittest.TestCase):

def test_spring_forward_scans_daily_rules_using_local_day_boundary(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这条夏令时回归测试在隔离环境中通过,但当前 GitHub Actions 不会运行它:workflow 调用 dtable_events/tests/test.sh test,该脚本只执行 SQL 和 webhook 测试,没有收集 tests/test_scheduled_automation.py。因此即使退回固定 UTC 23 小时窗口,当前 CI 也不会用这条断言拦截。请把这条测试加入 CI 的执行清单,并确认日志实际收集该测试。

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审更新(f462761):前次针对 #899 的发布阻塞不再适用:本版撤回配置时区调度和 scheduled_at,无需为了此 PR 先发布识别该字段的 worker。生产者和消费者仍应使用相同的进程时区。纽约春季前拨相隔 23 小时时的漏入队已恢复到目标分支及旧提醒的既有行为,不算本 PR 新引入;被撤回的回归测试应在未来修复时恢复并接入 CI。两处结论已更新在原夏令时线程及原消费端线程。本次仅验证入队和执行门槛;迁移整体仍受 dtable-web #6244 的迁移时区与缓存问题约束。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants